package com.zw.log.controller;/*
 *@program:java-cloud-prevalence
 *@author:zw
 *@Time: 2022/12/13
 *@description: feign调用异步保存操作日志
 */

import com.zw.log.service.SysOperLogService;
import com.zw.object.system.SysOperLog;
import com.zw.object.vo.OperLogUpdate;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "Feign远程调用保存操作日志")
@RestController
@RequestMapping("/admin/system/operlog")
public class AsyncOperLogController {
    @Autowired
    private SysOperLogService sysOperLogService;

    /**
     * 异步保存操作日志接口
     *
     * @param sysOperLog 参数对象
     */
    @ApiOperation("异步保存操作日志")
    @PostMapping("/feignSaveOperLog")
    public String sysOperLogSaveFeign(@RequestBody SysOperLog sysOperLog) {
        return sysOperLogService.sysOperLogSave(sysOperLog);
    }

    @ApiOperation("异步更新操作日志结果")
    @PostMapping("/feignUpdateOperLog")
    public void updateOperLog(@RequestBody OperLogUpdate operLogUpdate) {
        sysOperLogService.afterLog(operLogUpdate.getId(), operLogUpdate.getJsonResult());
    }
}
